package language;

import compiler.Sup;
import static java.util.Collections.EMPTY_MAP;
import java.util.Map;
import java.util.function.Supplier;

public abstract class LSupplier<T extends LType> extends LType implements Sup {

    public static <T extends LType> LSupplier<T> of(Supplier<T> supplier) {
        return new LSupplier<T>() {
            @Override
            public T get(Map<Character, LType> vars) {
                return supplier.get();
            }
        };
    }

    @Override
    public abstract T get(Map<Character, LType> vars);

    @Override
    public String toString() {
        return get(EMPTY_MAP).toString();
    }
}
